<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a new FFI object</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="ffi.cast.html">« FFI::cast</a></li>
      <li style="float: right;"><a href="ffi.free.html">FFI::free »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.ffi.html">FFI</a></li>
    <li>Creates a new FFI object</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="ffi.cdef" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">FFI::cdef</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">FFI::cdef</span> &mdash; <span class="dc-title">Creates a new FFI object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-ffi.cdef-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>FFI::cdef</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$code</code><span class="initializer"> = &quot;&quot;</span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$lib</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><a href="class.ffi.html" class="type FFI">FFI</a></span></div>

  <p class="para rdfs-comment">
   Creates a new FFI object.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-ffi.cdef-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">code</code></dt>

    <dd>

     <p class="para">
      A string containing a sequence of declarations in regular C language
      (types, structures, functions, variables, etc). Actually, this string may
      be copy-pasted from C header files.
     </p>
     <blockquote class="note"><p><strong class="note">注意</strong>: 
      <p class="para">
       C preprocessor directives are not supported, i.e. <code class="code">#include</code>, 
       <code class="code">#define</code> and CPP macros do not work.
      </p>
     </p></blockquote>
    </dd>

   
   
    <dt>
<code class="parameter">lib</code></dt>

    <dd>

     <p class="para">
      The name of a shared library file, to be loaded and linked with the
      definitions.
     </p>
     <blockquote class="note"><p><strong class="note">注意</strong>: 
      <p class="para">
       If <code class="parameter">lib</code> is omitted, platforms supporting <code class="literal">RTLD_DEFAULT</code>
       attempt to lookup symbols declared in <code class="parameter">code</code> in the normal global
       scope. Other systems will fail to resolve these symbols.
      </p>
     </p></blockquote>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-ffi.cdef-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the freshly created <span class="classname"><a href="class.ffi.html" class="classname">FFI</a></span> object.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-ffi.cdef-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">lib</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


</div></div></div></body></html>